package com.pda.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.Date;
import java.util.concurrent.TimeUnit;

/**
 * @author wzh
 * @version 1.0
 * @data 2025/5/15 15:13
 */
public class httpUtils {

    @Autowired
    private RedisTemplate<String,String> redisTemplate;

    public String getThirdToken() {
        String thirdToken = redisTemplate.opsForValue().get("ThirdToken");
        if(thirdToken == null) {
            try {
                //  获取边侧token
                thirdToken = getThirdTokenFromHttp();
            }catch(Exception ex) {
                thirdToken = "";
            }
            // 设置暂定过期时间为一个小时,后续根据端侧或变成token时间定
            redisTemplate.opsForValue().set("ThirdToken", thirdToken,3600, TimeUnit.SECONDS);
        }
        return thirdToken;
    }

    private String getThirdTokenFromHttp() throws Exception {

        return "token--- ";
    }

}
